/**
 * @author Ahammer
 * @date   2010 05
 * @update 
 */

/*
 * This file is part of Iqm.
 * Copyright (c) 2010-2011 Helmut Ahammer
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package opjai;
import javax.media.jai.JAI;
import javax.media.jai.OperationDescriptorImpl;
import javax.media.jai.OperationRegistry;
import javax.media.jai.registry.RIFRegistry;
import javax.media.jai.util.Range;

/**
 * This class defines the PointOpImage operator  for JAI
 * 
 */
public class IqmWatershedDescriptor extends OperationDescriptorImpl {
	
  private static final String[][] resources = {
      {"GlobalName",   "IqmWatershed"},
      {"LocalName",    "IqmWatershed"},
      {"Vendor",       "mug.qmnm"},
      {"Description",  "Watershed of an image"},
      {"DocURL",       "http://code.google.com/p/iqm/"},
      {"Version",      "1.0"},    
      {"arg0Desc",     "Invert"},       //Invert 0 no invert, 1 invert
      {"arg1Desc",     "PreProc"},      //PreProcessing: 0 none, 1 gaussian blur
      {"arg2Desc",     "Kernel"},       //kernelsize
      {"arg3Desc",     "Connectivety"}, //0 4-connectivety, 1 8-connectivety
      {"arg4Desc",     "ThresMin"},  //threshold min  [0,255]
      {"arg5Desc",     "ThresMax"},  //threshold max  [0,255]
      {"arg6Desc",     "Output"}, 	 //output option: 0 dams, 1 overlaid dams, 2 colorized basins, 3 composite  
  };
  private static final String[] supportedModes   = {"rendered"};
  private static final int      numSources       = 1;
  private static final String[] paramNames       = {"Invert", "PreProc", "Kernel", "Connectivety", "ThresMin", "ThresMax", "Output"};
  private static final Class[]  paramClasses     = {Integer.class, Integer.class, Integer.class, Integer.class, Integer.class, Integer.class, Integer.class};
  private static final Object[] paramDefaults    = {0, 0, 3, 0, 0, 255, 1};   
  private static final Range[]  validParamValues = {new Range(Integer.class, 0, 1),
	  												new Range(Integer.class, 0, 1),
	  												new Range(Integer.class, 0, Integer.MAX_VALUE),
	  												new Range(Integer.class, 0, 1),
	  												new Range(Integer.class, 0, 255),
	  												new Range(Integer.class, 0, 255),
  													new Range(Integer.class, 0, 3)};
 
 /**
  * constructor
  */ 
  public IqmWatershedDescriptor() {
    super(resources, supportedModes, numSources, paramNames, paramClasses, paramDefaults, validParamValues);
  }

 /**
  * This method registers this method 
  */
  public static void register() {
      OperationRegistry opReg = JAI.getDefaultInstance().getOperationRegistry();   
      IqmWatershedDescriptor descriptor = new IqmWatershedDescriptor();
      opReg.registerDescriptor(descriptor);  
      IqmWatershedRIF rif = new IqmWatershedRIF();
      RIFRegistry.register(opReg, "IqmWatershed", "Iqm", rif);
   }
  
} //END
